package ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import javax.swing.LayoutStyle.ComponentPlacement;

public class AboutDialog extends JDialog{
	private static final long serialVersionUID = 7842563607059033693L;
	public AboutDialog(JFrame frame) {
		super(frame);
		setLocation(new Point(400, 200));
		setSize(new Dimension(550, 350));
		setTitle("About");
		getContentPane().setSize(new Dimension(550, 380));
		getContentPane().setLocation(new Point(400, 200));
		
		JPanel aboutPanel = new JPanel();
		aboutPanel.setBackground(SystemColor.controlLtHighlight);
		aboutPanel.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		
		JButton btnOk = new JButton("Close");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
			}
		});
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(aboutPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
						.addComponent(btnOk, Alignment.TRAILING))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(aboutPanel, GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(btnOk)
					.addGap(8))
		);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon(AboutDialog.class.getResource("/icons/traff-sim_logo.png")));
		GroupLayout gl_aboutPanel = new GroupLayout(aboutPanel);
		gl_aboutPanel.setHorizontalGroup(
			gl_aboutPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_aboutPanel.createSequentialGroup()
					.addGap(20)
					.addComponent(label)
					.addContainerGap(302, Short.MAX_VALUE))
		);
		gl_aboutPanel.setVerticalGroup(
			gl_aboutPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_aboutPanel.createSequentialGroup()
					.addGap(20)
					.addComponent(label)
					.addContainerGap(22, Short.MAX_VALUE))
		);
		aboutPanel.setLayout(gl_aboutPanel);
		getContentPane().setLayout(groupLayout);
	}


}
